package com.fh.util;

import java.net.URL;

import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;

// 短信提供商 阿里大于
public class AliSmsUtil {
	private static final String URL = "http://gw.api.taobao.com/router/rest";
	private static final String APP_KEY = "23646012";
	private static final String SECRECT = "b84adae9e29fec525c6feedb7bed1725";
	private static final String SMS_TYPE = "SMS_48745027";
	private static final String SMS_SIGN = "Ccode人才";
	
	public static String sendSMS(String phoneNum,String validateCode) throws Exception{
		
		TaobaoClient client = new DefaultTaobaoClient(URL, APP_KEY, SECRECT);
		AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
		// 公共回传参数，在“消息返回”中会透传回该参数；举例：用户可以传入自己下级的会员ID，在消息返回时，该会员ID会包含在内
		// 短信类型
		req.setSmsType("normal");
		req.setSmsFreeSignName(SMS_SIGN);
		// 验证码
		req.setSmsParamString("{\"code\":\""+validateCode+"\"}");
		// 短信接收号码
		req.setRecNum(phoneNum);
		// 短信模板
		req.setSmsTemplateCode(SMS_TYPE);
		AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
		return rsp.getBody();
	}
	
	
}
